<?php get_header(); ?>
<div class="cy-content">
	<?php get_sidebar();?>
    <div class="cy-content-center">
     <?php locate_template('block/block-search.php', true); ?>
    <div class="cy-content-title">
    <h2>camera quan sát</h2>
    </div><!--cy-content-title-->
    <ul class="cy-products">
    <?php 	  
    // Get terms for post
	$terms = get_terms("danh_muc_san_pham");
				 $count = count($terms);
				 if ( $count > 0 ){
				foreach ( $terms as $term ) {	
   				?>
       <li class="cy-product-item">
            <div class="cy-product-title">
                <span class="cy-product-item-f"><?php 
    		      echo  $term->name;
    	 ?></span><!--cy-product-item-f-->     	
                <ul id="tab_product" class="tab_product">
                <?php
                $temm=1;
            	$loop = new WP_Query(array('post_type'=>'san_pham','danh_muc_san_pham'=>$term->slug,'order'=>'DESC'));?>
                <?php while ( $loop->have_posts() ) : $loop->the_post(); //bat dau vong lap ?>
                    <li <?php if($temm==1){echo "class='active'";}?><a href="#<?php  echo $term->slug;echo '-'; echo $post->ID;?>"><?php the_title();?></a></li>
                    <?php endwhile; //ket thuc vong lap ?>
                    <?php wp_reset_query();?>
    			</ul>
            </div><!--cy-product-title-->
            
            <?php
            $loop1 = new WP_Query(array('post_type'=>'san_pham','danh_muc_san_pham'=>$term->slug,'order'=>'DESC'));?>
            <?php while ( $loop->have_posts() ) : $loop->the_post(); //bat dau vong lap 
             ?>
             <div id="<?php  echo $term->slug;echo '-'; echo $post->ID;?>"  class="cy-product-content">
             <img src="<?php echo get('hinh');?>" />
                              <div class="cy-title-product"><a href="<?php the_permalink();?>"><?php the_title() ?></a></div>
                        <ul class="cy-product-content-i" >
                            <li>Mã sản phẩm : <?php echo get('ma_san_pham');?></li>
                            <li>Đơn vị tính : <?php echo get('don_vi_tinh');?></li>
                            <li>Xuất xứ : <?php echo get('xuat_xu');?></li>
                            <li>Trạng thái: <?php if(get('trang_thai')==0){echo "Còn hàng";}else{echo "Hết hàng";};?></li>
                        </ul><!--cy-product-content-->
                        <div class="cy-product-extensions">
                            <a href="<?php the_permalink();?>"><div class="cy-read-more"></div></a><!--cy-read-more-->
        					<?php if(trim(get('gia_khuyen_mai')) !=""){?>
                             <div class="cy-price-gach">
                             Giá : <?php echo number_format(get('gia'),0);?> VNĐ
                             </div><!--cy-price-gach-->
                             <div class="cy-price-km">
                             Giá khuyến mãi : <?php echo number_format(get('gia_khuyen_mai'),0);?> VNĐ
                             </div><!--cy-price-km-->
                        <?php }else{?>
                        <div class="cy-price">
                        Giá : <?php echo number_format(get('gia'),0);?> VNĐ
                        </div><!--cy-price-->
                        <?php } ?>
                        </div><!--cy-product-extensions-->
               </div><!--cy-product-content-->
          <?php  endwhile; 
          //ket thuc vong lap ?>
          <?php wp_reset_query();?>
            
        </li>
        		<?php 
				 }
   				?>
        <?php    
		} ?>
    </ul>
    </div><!--cy-content-center-->  
</div><!--cy-content-->
<?php get_footer(); ?>